package com.jcl.recruit.verfity.dao;

import com.jcl.core.db.DatabaseContext;
import com.jcl.recruit.verfity.model.VerificationCode;
import com.jcl.recruit.verifty.mapper.VerificationCodeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.Date;

@Component
public class VerificationCodeDao implements VerificationCodeMapper {

    @Autowired
    private VerificationCodeMapper verificationCodeMapper;


    @Override
    public VerificationCode findOneByType(String receiver, Integer type) {
        DatabaseContext.setCurrentContext();
        return verificationCodeMapper.findOneByType(receiver, type);
    }

    @Override
    public VerificationCode validateTime(String receiver, Integer type, Date abateDate) {
        DatabaseContext.setCurrentContext();
        return verificationCodeMapper.validateTime(receiver, type, abateDate);
    }

    @Override
    public VerificationCode validateCode(String receiver, Integer type, String code) {
        DatabaseContext.setCurrentContext();
        return verificationCodeMapper.validateCode(receiver, type, code);
    }

    @Override
    public int add(VerificationCode verificationCode) {
        DatabaseContext.setCurrentContext();
        return verificationCodeMapper.add(verificationCode);
    }

    @Override
    public int delete(String receiver, Integer type) {
        DatabaseContext.setCurrentContext();
        return verificationCodeMapper.delete(receiver, type);
    }
}
